#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int q;
    cin >> q;
    int a, b, c;
    int s = 0;
    while (q--)
    {
        cin >> a >> b >> c;
        while ((a != 0) && (b != 0) && (c != 0))
        {
            a--;
            b--;
            c--;
            s += 2;
        }
        if (b > 2)
        {
            s += b - 1;
        }
        cout << s << endl;
    }

}